function [m ] = quat2mat(q)
% This code is different from quat2dcm (Matlab library).

Dsvx = 2*q(1)*q(2);
Dsvy = 2*q(1)*q(3);
Dsvz = 2*q(1)*q(4);

DvxQ = 2*q(2)*q(2);
DvyQ = 2*q(3)*q(3);
DvzQ = 2*q(4)*q(4);

Dvxvy = 2*q(2)*q(3);
Dvxvz = 2*q(2)*q(4);
Dvyvz = 2*q(3)*q(4);

m = [1 - DvyQ - DvzQ, Dvxvy - Dsvz, Dvxvz + Dsvy; Dvxvy + Dsvz, 1 - DvxQ - DvzQ, Dvyvz - Dsvx; Dvxvz - Dsvy, Dvyvz + Dsvx, 1 - DvxQ - DvyQ];